home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Reference / the cmsp digests ('94-'97) / csmp digest Vol 3 No 071 < prev    next >
Internet Message Format  |  1997-05-06  |  46KB

  1. From: pottier@clipper.ens.fr (Francois Pottier)
  2. Subject: csmp-digest-v3-071
  3. Date: Mon, 28 Nov 1994 18:41:24 +0100 (MET)
  4.  
  5. C.S.M.P. Digest             Mon, 28 Nov 94       Volume 3 : Issue 71
  6.  
  7. Today's Topics:
  8.  
  9.         (PPC) MDEF's in application code
  10.         Getting The PSN or Sig of AE Client
  11.         Is THINK Pascal dead?
  12.         Newbie Q:Why no DisposeHandle-ReleaseResource call?
  13.         Prograph 2.5
  14.         [Q] Programming with the QuickTime toolkit
  15.  
  16.  
  17.  
  18. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  19. (pottier@clipper.ens.fr).
  20.  
  21. The digest is a collection of article threads from the internet newsgroup
  22. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  23. regularly and want an archive of the discussions.  If you don't know what a
  24. newsgroup is, you probably don't have access to it.  Ask your systems
  25. administrator(s) for details.  If you don't have access to news, you may
  26. still be able to post messages to the group by using a mail server like
  27. anon.penet.fi (mail help@anon.penet.fi for more information).
  28.  
  29. Each issue of the digest contains one or more sets of articles (called
  30. threads), with each set corresponding to a 'discussion' of a particular
  31. subject.  The articles are not edited; all articles included in this digest
  32. are in their original posted form (as received by our news server at
  33. nef.ens.fr).  Article threads are not added to the digest until the last
  34. article added to the thread is at least two weeks old (this is to ensure that
  35. the thread is dead before adding it to the digest).  Article threads that
  36. consist of only one message are generally not included in the digest.
  37.  
  38. The digest is officially distributed by two means, by email and ftp.
  39.  
  40. If you want to receive the digest by mail, send email to listserv@ens.fr
  41. with no subject and one of the following commands as body:
  42.     help                        Sends you a summary of commands
  43.     subscribe csmp-digest Your Name    Adds you to the mailing list
  44.     signoff csmp-digest            Removes you from the list
  45. Once you have subscribed, you will automatically receive each new
  46. issue as it is created.
  47.  
  48. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  49. Questions related to the ftp site should be directed to
  50. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  51. digest are available there.
  52.  
  53. Also, the digests are available to WAIS users.  To search back issues
  54. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  55. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  56.  
  57.  
  58. -------------------------------------------------------
  59.  
  60. >From tcarsten@cayman.jpmorgan.com (Tom Carstensen)
  61. Subject: (PPC) MDEF's in application code
  62. Date: 25 Oct 1994 16:25:54 GMT
  63. Organization: J.P. Morgan & Co
  64.  
  65.  
  66. Before PPC, I would load a stub 'MDEF' and set the proc ptr:
  67.  
  68. typedef struct GenericMDEF {
  69.     short        JMPInstruction;
  70.     void        *defProc;
  71. } GenericMDEF;
  72.  
  73.    mdefHdl = GetResource('MDEF', 200);        /* sub def */
  74.    
  75.     (**((GenericMDEF **) mdefHdl)).defProc = myMdefProc;
  76.  
  77.  
  78. NOW, with PPC, I'm doing:
  79.  
  80.     (**((GenericMDEF **) mdefHdl)).defProc = NewMenuDefProc(myMdefProc);
  81.  
  82. which, with code warrior, creates a new routine descriptor, and sets it up
  83. appropriately.
  84.  
  85. This does not work.  I've read IM PowerPC System Software - but it's 
  86. somewhat confusing.  If I'm defining an accelerated resource, than I need
  87. a routine descriptor that tells what kind of code is ahead.  I thought
  88. the above should work, assuming the menu manager uses CallUniversalProc
  89. to call the menu definition procedure.
  90.  
  91. BTW - I'm using Code warrior in the above example.
  92.  
  93. Thanks for any hints.
  94.  
  95. Tom Carstensen
  96. --
  97. --                    ___
  98. Thomas Carstensen          //__/  60 Wall Street  17th Floor
  99.   tcarsten@jpmorgan.com      /__//      New York, NY  10260
  100.   tomc@digex.access.net      Morgan     212.648.4584
  101.  
  102. +++++++++++++++++++++++++++
  103.  
  104. >From d88-bli@xbyse.nada.kth.se (Bo Lindbergh)
  105. Date: 31 Oct 1994 16:31:38 GMT
  106. Organization: Royal Institute of Technology, Stockholm, Sweden
  107.  
  108. In article <TCARSTEN.94Oct25122554@cayman.jpmorgan.com> tcarsten@cayman.jpmorgan.com (Tom Carstensen) writes:
  109.  
  110. [mostly correct example of stub MDEF hacking deleted]
  111.  
  112. Try bracketing the struct definition with alignment pragmas:
  113.  
  114.     #if defined(powerc) || defined (__powerc)
  115.     #pragma options align=mac68k
  116.     #endif
  117.  
  118.     typedef struct GenericMDEF {
  119.         short       JMPInstruction;
  120.         void        *defProc;
  121.     } GenericMDEF;
  122.  
  123.     #if defined(powerc) || defined(__powerc)
  124.     #pragma options align=reset
  125.     #endif
  126.  
  127. Without them, you'll get two bytes of padding between the short and the
  128. void *.
  129.  
  130.  
  131. /Bo Lindbergh
  132.  
  133. +++++++++++++++++++++++++++
  134.  
  135. >From Graham@impro.demon.co.uk (Graham)
  136. Date: Wed, 9 Nov 1994 17:02:12 GMT
  137. Organization: N/A
  138.  
  139. I use the following routines to do this- on 68K macs it defaults to the
  140. old way of creating a stub for the jump, on PowerMacs it creates a
  141. routine dscriptor, so the same code works in all cases. try it.
  142.  
  143. #include    "MixedMode.h"
  144.  
  145. typedef struct
  146. {
  147.    short   Jmp;            // jmp instruction
  148.    void*   Routine;        // address to jump to
  149. }
  150. JmpInstructionTemplate;
  151.  
  152.  
  153. Handle    GetUniversalFunctionHandle(ProcPtr functionAddress,ProcInfoType
  154. pInfo);
  155. void     PatchJmpInstruction(void* patchAddress, void* jumpAddress);
  156.  
  157.  
  158.  
  159. Handle    GetUniversalFunctionHandle(ProcPtr functionAddress,ProcInfoType
  160. pInfo)
  161. {
  162.     Handle                pHNullProc = NULL;
  163.     ISAType                isa;
  164.     UniversalProcPtr     axDEFUPP;
  165.     
  166.     isa = GetCurrentISA();
  167.     
  168.     if (isa == kPowerPCISA)
  169.     {
  170.        pHNullProc = NewHandle(sizeof(RoutineDescriptor));
  171.        axDEFUPP = NewRoutineDescriptor(functionAddress,pInfo,isa);
  172.        BlockMove(axDEFUPP, *pHNullProc, sizeof(RoutineDescriptor));
  173.        DisposeRoutineDescriptor(axDEFUPP);
  174.     }
  175.     else
  176.     {
  177.        pHNullProc = NewHandle(sizeof(JmpInstructionTemplate));
  178.        PatchJmpInstruction(*pHNullProc, (void*)functionAddress);
  179.     }
  180.     return(pHNullProc);
  181. }
  182.  
  183.  
  184. void PatchJmpInstruction(void* patchAddress, void* jumpAddress)
  185. {
  186.    JmpInstructionTemplate* aJmpInstructionPtr;
  187.    
  188.    aJmpInstructionPtr = (JmpInstructionTemplate *) patchAddress;
  189.    aJmpInstructionPtr->Jmp = 0x4EF9;
  190.    aJmpInstructionPtr->Routine = jumpAddress;
  191. }
  192.  
  193.  
  194. You have to pass the proc info type for the routine, which youll have
  195. to look up in the universal headers, and the proc ptr to your MDEF
  196. function, it returns a handle which you simply stuff into the relevant
  197. defProc field.
  198. Apple DTS gave me the bones for this, so it even has the "official"
  199. stamp of approval!
  200.  
  201. ************************************************************************
  202. *
  203. MHROTD, Graham.  (Sorry, I haven't got time to think of
  204.                                        a witty signature)
  205.  
  206. +++++++++++++++++++++++++++
  207.  
  208. >From rang@winternet.com (Anton Rang)
  209. Date: 10 Nov 1994 14:33:59 GMT
  210. Organization: Trillium Research, Inc.
  211.  
  212. In article <Cz0FBo.FvL@demon.co.uk> Graham@impro.demon.co.uk (Graham) writes:
  213. >I use the following routines to do this- on 68K macs it defaults to the
  214. >old way of creating a stub for the jump, [...]
  215.  
  216.   Don't forget the posting last month from someone who had created a
  217. six-byte handle to hold their 'JMP $xxx' instruction and found that
  218. when the handle was moved by the memory manager, the i-cache wasn't
  219. flushed 'cause the handle was too small.  :)
  220. --
  221. Anton Rang (rang@winternet.com)
  222.  
  223. +++++++++++++++++++++++++++
  224.  
  225. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  226. Date: Fri, 11 Nov 1994 05:15:43 +1200 (NZST)
  227. Organization: (none)
  228.  
  229. rang@winternet.com (Anton Rang) writes:
  230. > In article <Cz0FBo.FvL@demon.co.uk> Graham@impro.demon.co.uk (Graham) writes:
  231. > >I use the following routines to do this- on 68K macs it defaults to the
  232. > >old way of creating a stub for the jump, [...]
  233. >   Don't forget the posting last month from someone who had created a
  234. > six-byte handle to hold their 'JMP $xxx' instruction and found that
  235. > when the handle was moved by the memory manager, the i-cache wasn't
  236. > flushed 'cause the handle was too small.  :)
  237.  
  238. I missed that one.
  239.  
  240. But I've never understood why people use the "six-byte resource" trick
  241. when it's so easy to use a "ten-byte resource" trick that is I-cache
  242. safe.
  243.  
  244. -- Bruce
  245.  
  246. ---------------------------
  247.  
  248. >From Jonathan Gary <jgary@ssd.kodak.com>
  249. Subject: Getting The PSN or Sig of AE Client
  250. Date: Tue, 8 Nov 1994 19:59:50 GMT
  251. Organization: Eastman Kodak
  252.  
  253. I'm trying to get the the PSN of the process that sends me an AE. I can
  254. get the
  255. address from the event, but how do I get at the PSN?
  256.  
  257. +++++++++++++++++++++++++++
  258.  
  259. >From wysocki@netcom.com (Chris Wysocki)
  260. Date: Fri, 11 Nov 1994 06:52:40 GMT
  261. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  262.  
  263. In article <Cyysvr.2yK@newsserver.pixel.kodak.com>,
  264. Jonathan Gary  <jgary@ssd.kodak.com> wrote:
  265.  
  266. >I'm trying to get the the PSN of the process that sends me an AE. I can
  267. >get the address from the event, but how do I get at the PSN?
  268.  
  269. The following routine should work:
  270.  
  271. // ----------------------------------------------------------------------
  272. // CAppleEvent::GetProcessSerialNumber
  273. // ----------------------------------------------------------------------
  274.  
  275. void CAppleEvent::GetProcessSerialNumber(ProcessSerialNumber& thePSN) const
  276. {
  277.     DescType actualType;
  278.     Size actualSize;
  279.     TargetID theTargetID;
  280.     
  281.     FailOSErr(AEGetAttributePtr(&fMessage, keyAddressAttr, typeTargetID,
  282.               &actualType, &theTargetID, sizeof(theTargetID), &actualSize));
  283.     FailOSErr(GetProcessSerialNumberFromPortName(&theTargetID.name, &thePSN));
  284. }
  285.  
  286. I believe that the sending process needs to be running on the same
  287. machine as the target process for this to work, since PSNs are only
  288. unique to a particular machine.
  289.  
  290. Chris.
  291.  
  292.  
  293.  
  294. ---------------------------
  295.  
  296. >From bernier@dialup.francenet.fr (Jean-Yves Bernier)
  297. Subject: Is THINK Pascal dead?
  298. Date: Fri, 04 Nov 1994 11:14:55 +0100
  299. Organization: SPECTRA Soft
  300.  
  301.  
  302. Excuse-me if the topic has already been discussed here (I am a newcomer)
  303. but I have see no such thing in the 100 last articles, and I could not
  304. figure a more suitable group.
  305.  
  306. I am one of the many THINK Pascal users left in the dark by Symantec, after
  307. the PowerPC. I have thousand of lines of Pascal to port to the PowerPC and
  308. I don't want to loose the advantages of THINK Pascal (the wonderful
  309. source-level debugger, among others).
  310.  
  311. What is the official status of THINK Pascal? Will ever exist a PowerPC
  312. version? Is it dead? I am a registered user, but I receive absolutely no
  313. information from Symantec. Have they e-mail support?
  314.  
  315. Thanks.
  316.  
  317.  
  318.  
  319. - -------------------------
  320. Jean-Yves Bernier - SPECTRA
  321. bernier@dialup.francenet.fr
  322. - -------------------------
  323.  
  324.  
  325. +++++++++++++++++++++++++++
  326.  
  327. >From nick+@pitt.edu ( nick.c )
  328. Date: Fri, 04 Nov 1994 10:49:30 -0500
  329. Organization: The Pitt, Chemistry
  330.  
  331.  
  332.    Yes, very dead.  I would not expect any udates or new versions.
  333.      That said a lot of folks still use it.  It should be possible to
  334.      port your code to CodeWarrrior Pascal (one of the compilers 
  335.      included with the CodeWarrior Gold or Bronze CD).  The Gold
  336.      version runs native (fat - I think) and compiles for PPC.
  337.  
  338.  
  339.  Internet: nick+@pitt.edu            _/   _/  _/  _/_/_/   _/   _/  
  340.    eWorld: nick                     _/_/ _/  _/  _/   _/  _/_/_/ 
  341.       CIS: 71232,766               _/ _/_/  _/  _/       _/ _/    
  342.      http://www.pitt.edu/~nick/   _/   _/  _/   _/_/_/  _/   _/     
  343.                     
  344.  
  345. +++++++++++++++++++++++++++
  346.  
  347. >From lbotez@picard.cs.wisc.edu (Lynda Botez)
  348. Date: 6 Nov 1994 17:36:45 GMT
  349. Organization: U of Wisconsin CS Dept
  350.  
  351. Er, Think Pascal isn't really dead, it's just comatose.
  352.  
  353. If you need to convert stuff over to the powerpc, though, I would suggest
  354. you look into CodeWarrior. They actually have a pascal powerpc compiler
  355. (its in beta, but I would imagine it works pretty good)... and I doubt
  356. Symantec will bother with Think Pascal.  
  357.  
  358. Also, I think most of the programmers that developed Think Pascal are now
  359. working for Metrowerks (the company that owns CodeWarrior); so you can
  360. imagine that Think Pascal is not long for this world..
  361.  
  362.  
  363. +++++++++++++++++++++++++++
  364.  
  365. >From johnmce@world.std.com (John McEnerney)
  366. Date: Sun, 6 Nov 1994 19:11:16 GMT
  367. Organization: The World Public Access UNIX, Brookline, MA
  368.  
  369. lbotez@picard.cs.wisc.edu (Lynda Botez) writes:
  370.  
  371. >Also, I think most of the programmers that developed Think Pascal are now
  372. >working for Metrowerks (the company that owns CodeWarrior); so you can
  373. >imagine that Think Pascal is not long for this world..
  374.  
  375. For anyone who's interested, the programmers who developed THINK Pascal are:
  376.  
  377. Me (at Metrowerks these days)
  378. David Neal (director of Symantec's Mac language group)
  379. Rich Siegel (of Bare Bones software fame)
  380. Pete Maruhnic (author of CA's Realizer for Windows)
  381.  
  382. So only one of us ended up at Metrowerks. Still, the product is pretty 
  383. much dead wrt PowerPC, as much my fault as anyone else's: a lot of the 
  384. code was written in assembly language, the context-switch mechanism would 
  385. probably not survive a port to the PPC, etc. It is rumored that Symantec 
  386. still has plans in the Pascal arena (but as you might imagine they don't 
  387. tell me that sort of thing anymore)
  388.  
  389. -- John McEnerney, Metrowerks PowerPC Product Architect
  390.  
  391.  
  392. +++++++++++++++++++++++++++
  393.  
  394. >From RobTerrell@vmedia.com (Rob Terrell)
  395. Date: 6 Nov 1994 21:26:52 GMT
  396. Organization: Jecta Development Corp.
  397.  
  398. John McEnerney said:
  399. > So only one of us ended up at Metrowerks. Still, the product is pretty
  400. > much dead wrt PowerPC, as much my fault as anyone else's: a lot of the
  401. > code was written in assembly language, the context-switch mechanism
  402. > would probably not survive a port to the PPC, etc. It is rumored that
  403. > Symantec still has plans in the Pascal arena (but as you might imagine
  404. > they don't tell me that sort of thing anymore)
  405.  
  406. Yeah, there was a rumor in MacWeek regarding this. I doubt it. The
  407. Symantec folks were real arrogant on the topic of the death of Pascal
  408. at the WWDC.
  409.  
  410. So, John, what's happening with Metrowerks' Pascal? I would totally
  411. abandon Think Pascal if CW supported an Object Pascal.
  412.  
  413.  
  414. Rob
  415.  
  416. +++++++++++++++++++++++++++
  417.  
  418. >From siegel@netcom.com (Rich Siegel)
  419. Date: Mon, 7 Nov 1994 17:57:38 GMT
  420. Organization: Bare Bones Software
  421.  
  422. In article <39j47d$gfq@spool.cs.wisc.edu> lbotez@picard.cs.wisc.edu (Lynda Botez) writes:
  423. >
  424. >Also, I think most of the programmers that developed Think Pascal are now
  425. >working for Metrowerks (the company that owns CodeWarrior); so you can
  426. >imagine that Think Pascal is not long for this world..
  427. >
  428.  
  429. That is not true.
  430.  
  431. Of the four people most directly involved in the development of THINK Pascal:
  432.  
  433. - one is at Metrowerks
  434. - one is director of the development tools group at Symantec
  435. - one is off doing something else (I don't recall where)
  436. - one is president and CEO of his own software company
  437.  
  438. When this question was recently posted to Symantec personnel at a
  439. recent BCS MacTechGroup meeting, the response was (basically) that
  440. they plan to work with certain third-party compiler makers to produce
  441. a Pascal solution for Rainbow (their new development environment that
  442. is currently under development).
  443.  
  444. R.
  445. -- 
  446. Rich Siegel % siegel@netcom.com    % President & CEO, Bare Bones Software Inc.
  447. --> For information about BBEdit, finger bbedit@world.std.com <--
  448.  
  449. +++++++++++++++++++++++++++
  450.  
  451. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  452. Date: Tue, 08 Nov 1994 11:23:59 +0800
  453. Organization: NCRPDA, Curtin University
  454.  
  455. In article <39jhms$ja@redstone.interpath.net>, RobTerrell@vmedia.com (Rob
  456. Terrell) wrote:
  457.  
  458. >Yeah, there was a rumor in MacWeek regarding this. I doubt it. The
  459. >Symantec folks were real arrogant on the topic of the death of Pascal
  460. >at the WWDC.
  461.  
  462. A Symantec fellow told me that the rumour is crap.  There is no Symantec
  463. plans for a PPC pascal compiler.
  464.  
  465. >So, John, what's happening with Metrowerks' Pascal? I would totally
  466. >abandon Think Pascal if CW supported an Object Pascal.
  467.  
  468. You and me both.  I'm strugling on with THINK Pascal waiting for objects
  469. to show up in MW Pascal.  MW Pascal is scheduled to go 1.0 without objects
  470. in January (CW5), and MW Object Pascal is scheduled for CW6 in May (it
  471. better be there, otherwise Greg will have to face down some heckling at
  472. the WWDC :-).
  473.  
  474. The best you can do to help is to a) make sure MW knows that Object Pascal
  475. is what you need; b) buy MW CW; c) feed any bugs back to the MW bug report
  476. line as precisely as you can.  That's what i've been doing, an Marcel has
  477. been very good at fixing bugs (such that basically every bug I have
  478. reported has been fixed by the next version).
  479.  
  480. Enjoy,
  481.    Peter.
  482. -- 
  483. Peter N Lewis <peter.lewis@info.curtin.edu.au> - Macintosh TCP fingerpainter
  484. FTP my programs from redback.cs.uwa.edu.au:Others/PeterLewis/ or
  485. amug.org:pub/peterlewis/ or nic.switch.ch:software/mac/peterlewis/
  486.  
  487. +++++++++++++++++++++++++++
  488.  
  489. >From ingemar@lysator.liu.se (Ingemar Ragnemalm)
  490. Date: 8 Nov 1994 08:17:05 GMT
  491. Organization: (none)
  492.  
  493. johnmce@world.std.com (John McEnerney) writes:
  494.  
  495. >lbotez@picard.cs.wisc.edu (Lynda Botez) writes:
  496.  
  497. >>Also, I think most of the programmers that developed Think Pascal are now
  498. >>working for Metrowerks (the company that owns CodeWarrior); so you can
  499. >>imagine that Think Pascal is not long for this world..
  500.  
  501. >For anyone who's interested, the programmers who developed THINK Pascal are:
  502.  
  503. >Me (at Metrowerks these days)
  504. >David Neal (director of Symantec's Mac language group)
  505. >Rich Siegel (of Bare Bones software fame)
  506. >Pete Maruhnic (author of CA's Realizer for Windows)
  507.  
  508. >So only one of us ended up at Metrowerks. Still, the product is pretty 
  509. >much dead wrt PowerPC, as much my fault as anyone else's: a lot of the 
  510. >code was written in assembly language, the context-switch mechanism would 
  511. >probably not survive a port to the PPC, etc.
  512.  
  513. MetroWerks Pascal is sort of ok as replacement. It doesn't have Instant,
  514. it's debugger is far from the elegance of Lightsbug, but it works.
  515.  
  516. But I wonder, why wasn't the debugger integrated with the compiler?
  517. No flames, but I really didn't think a Think Pascal decveloper would
  518. let so many Think C flaw through.
  519.  
  520. Why mimick the clumsy Think C when Think Pascal is so much better (language
  521. issues aside). Imagine a system where you step and set breakpoints in the
  522. editor, while the editor and the debugger communicated with Apple Events.
  523. I can't see the problem, as long as we don't demand Instant.
  524.  
  525. >It is rumored that Symantec 
  526. >still has plans in the Pascal arena (but as you might imagine they don't 
  527. >tell me that sort of thing anymore)
  528.  
  529. Long ago, I bought Think C. It took several years before I got any feedback
  530. - probably that was after buying Think Pascal. When Symantec now tries to
  531. convince me that I should get SC++, I bought CodeWarrior instead. Much better
  532. C environment, and a future for my Pascal code.
  533.  
  534. Fortunately, my Think Pascal isn't dead yet. I guess it will stop working
  535. somewhere between 7.5 and 8.0 or so, but not yet.
  536.  
  537. --
  538. - -
  539. Ingemar Ragnemalm, PhD
  540. Image processing, Mac shareware games
  541. E-mail address: ingemar@isy.liu.se or ingemar@lysator.liu.se
  542.  
  543. +++++++++++++++++++++++++++
  544.  
  545. >From palais@binah.cc.brandeis.edu
  546. Date: 12 Nov 1994 19:55:02 GMT
  547. Organization: Brandeis University
  548.  
  549. One should also mention that Language Systems is making a very
  550. credible effort at developing an industrial strength Pascal
  551. compiler. Unlike CodeWarrior, the LS version runs under
  552. MPW, which you may or may not find an advantage. But for those
  553. of us who got hooked on Object Pascal before Apple pulled the
  554. rug out from under us, it is the only way to go, since it does
  555. compile Object Pascal while CodeWarrior does not.
  556.  
  557.    R. Palais
  558.  
  559. ---------------------------
  560.  
  561. >From roxanne@bnr.ca (Roxanne Friesen)
  562. Subject: Newbie Q:Why no DisposeHandle-ReleaseResource call?
  563. Date: Mon, 07 Nov 1994 11:53:32 -0400
  564. Organization: Bell-Northern Research Ltd.
  565.  
  566. I'm trying to get a better *handle* on when handles should be disposed of
  567. and resources released.
  568.  
  569. In the first sample function below, I would have thought that the alias
  570. handle should be disposed of once the resource has been written to the
  571. resource file but this function doesn't do that.  Am I wrong, is this
  572. function wrong, or is it simply not necessary, in this case, to dispose of
  573. the handle? (For the sake of simplifying the samples, assume I'm writing
  574. to my apps own resource fork and not a prefs file of some kind ... or does
  575. that make a difference?)
  576.  
  577. FUNCTION doCreateAlias(fileSpec:FSSpec):OSErr;
  578. VAR
  579.   alisHandle : AliasHandle;
  580.   result : OSErr;
  581.  
  582. BEGIN
  583.   result := NewAlias(NIL, fileSpec, alisHandle);
  584.   IF (alisHandle <> NIL) THEN BEGIN
  585.     AddResource(Handle(alisHandle), rAliasType, 128, 'File Alias');
  586.     result := ResError;
  587.  
  588.     IF (result = NoErr) THEN BEGIN
  589.       WriteResource(Handle(alisHandle));
  590.       result := ResError;
  591.     END;
  592.   END;
  593.  
  594.   doCreateAlias := result;
  595. END; {doCreateAlias}
  596.  
  597.  
  598. In the second sample function below, again, I would have thought that the
  599. resource should be released once I'm finished with it but, again, this
  600. function doesn't do that.  Am I wrong, is this function wrong, or is it
  601. simply not necessary, in this case, to release the resource?
  602.  
  603. FUNCTION setResStr(rsrcType:ResType; rsrcID:INTEGER; content:STR255):OSErr;
  604. VAR   
  605.   rsrcHdl : Handle;
  606.   result  : OSErr;
  607.          
  608. BEGIN
  609.   rsrcHdl := GetResource(rsrcType, rsrcID);
  610.   result := ResError;
  611.          
  612.   IF (rsrcHdl <> NIL) THEN BEGIN
  613.     SetHandleSize(rsrcHdl, LENGTH(content) + 1);          
  614.     BlockMove(@content, rsrcHdl^, LENGTH(content) + 1); 
  615.     ChangedResource(rsrcHdl);
  616.     result := ResError;                                              
  617.  
  618.     IF (result = NoErr) THEN BEGIN
  619.       WriteResource(rsrcHdl);
  620.       result := ResError;
  621.     END;                                       
  622.   END;
  623.   
  624.   setResStr :=
  625. result;                                                                    
  626.  
  627. END; {setResStr}
  628.  
  629.  
  630. Any help, hints, tips, suggestions would be appreciated.
  631. Roxanne.
  632.  
  633. -- 
  634. Roxanne Friesen
  635. Bell-Northern Research Ltd.
  636. roxanne@bnr.ca
  637.  
  638. +++++++++++++++++++++++++++
  639.  
  640. >From jones.794@osu.edu (Matt Jones)
  641. Date: Mon, 07 Nov 1994 19:15:24 +0500
  642. Organization: The Ohio State University
  643.  
  644. In article <roxanne-0711941153320001@47.221.33.54>, roxanne@bnr.ca (Roxanne
  645. Friesen) wrote:
  646.  
  647. > I'm trying to get a better *handle* on when handles should be disposed of
  648. > and resources released.
  649. > In the first sample function below, I would have thought that the alias
  650. > handle should be disposed of once the resource has been written to the
  651. > resource file but this function doesn't do that.  Am I wrong, is this
  652. > function wrong, or is it simply not necessary, in this case, to dispose of
  653. > the handle? (For the sake of simplifying the samples, assume I'm writing
  654. > to my apps own resource fork and not a prefs file of some kind ... or does
  655. > that make a difference?)
  656. > FUNCTION doCreateAlias(fileSpec:FSSpec):OSErr;
  657. > VAR
  658. >   alisHandle : AliasHandle;
  659. >   result : OSErr;
  660. > BEGIN
  661. >   result := NewAlias(NIL, fileSpec, alisHandle);
  662. >   IF (alisHandle <> NIL) THEN BEGIN
  663. >     AddResource(Handle(alisHandle), rAliasType, 128, 'File Alias');
  664. >     result := ResError;
  665. >     IF (result = NoErr) THEN BEGIN
  666. >       WriteResource(Handle(alisHandle));
  667. >       result := ResError;
  668. >     END;
  669. >   END;
  670. >  
  671. >   doCreateAlias := result;
  672. > END; {doCreateAlias}
  673. > In the second sample function below, again, I would have thought that the
  674. > resource should be released once I'm finished with it but, again, this
  675. > function doesn't do that.  Am I wrong, is this function wrong, or is it
  676. > simply not necessary, in this case, to release the resource?
  677. > FUNCTION setResStr(rsrcType:ResType; rsrcID:INTEGER; content:STR255):OSErr;
  678. > VAR   
  679. >   rsrcHdl : Handle;
  680. >   result  : OSErr;
  681. >          
  682. > BEGIN
  683. >   rsrcHdl := GetResource(rsrcType, rsrcID);
  684. >   result := ResError;
  685. >          
  686. >   IF (rsrcHdl <> NIL) THEN BEGIN
  687. >     SetHandleSize(rsrcHdl, LENGTH(content) + 1);          
  688. >     BlockMove(@content, rsrcHdl^, LENGTH(content) + 1); 
  689. >     ChangedResource(rsrcHdl);
  690. >     result := ResError;                                              
  691. >     IF (result = NoErr) THEN BEGIN
  692. >       WriteResource(rsrcHdl);
  693. >       result := ResError;
  694. >     END;                                       
  695. >   END;
  696. >   
  697. >   setResStr :=
  698. > result;                                                                    
  699. > END; {setResStr}
  700. > Any help, hints, tips, suggestions would be appreciated.
  701. > Roxanne.
  702. > -- 
  703. > Roxanne Friesen
  704. > Bell-Northern Research Ltd.
  705. > roxanne@bnr.ca
  706.  
  707. If your compiler is any good, it checks if any of the handles in local
  708. storage are still attached. ( I think ) Otherwise, you would be unable to
  709. find the handles to dispose of them later. However, this is tricky internal
  710. compiler stuff, much like pre-initialized variables. I always explicitly
  711. dispose of handles since the moment you assume your compiler does it for
  712. you, it stops.
  713. - ------------------------------------------------------------------------
  714. | it won't give up it wants me dead | |\  | | |  /| | jones.794          |
  715. | goddamn this noise inside my head | | \ | | | / | |    @ohio-state.edu |
  716. |                   Trent Reznor    | |  \| | |/  | | Stop the Clipper!  |
  717. - ------------------------------------------------------------------------
  718.  
  719. +++++++++++++++++++++++++++
  720.  
  721. >From sigurasg@rhi.hi.is (Sigurdur Asgeirsson)
  722. Date: Tue, 08 Nov 1994 09:49:56 -0100
  723. Organization: University of Iceland
  724.  
  725. In article <roxanne-0711941153320001@47.221.33.54>, roxanne@bnr.ca
  726. (Roxanne Friesen) wrote:
  727.  
  728. [snip]
  729.  
  730. > In the first sample function below, I would have thought that the alias
  731. > handle should be disposed of once the resource has been written to the
  732. > resource file but this function doesn't do that.  Am I wrong, is this
  733. > function wrong, or is it simply not necessary, in this case, to dispose of
  734. > the handle?
  735.  
  736. [snip]
  737.  
  738. > FUNCTION doCreateAlias(fileSpec:FSSpec):OSErr;
  739. > VAR
  740. >   alisHandle : AliasHandle;
  741. >   result : OSErr;
  742. > BEGIN
  743. >   result := NewAlias(NIL, fileSpec, alisHandle);
  744. >   IF (alisHandle <> NIL) THEN BEGIN
  745. >     AddResource(Handle(alisHandle), rAliasType, 128, 'File Alias');
  746. >     result := ResError;
  747. >     IF (result = NoErr) THEN BEGIN
  748. >       WriteResource(Handle(alisHandle));
  749. >       result := ResError;
  750. >     END;
  751. >   END;
  752. >  
  753. >   doCreateAlias := result;
  754. > END; {doCreateAlias}
  755. [second code example snipped for brevity]
  756.  
  757.   There is no need in this case to dispose the handle, unless the
  758. AddResource call fails, in which case the handle should be disposed of
  759. with DisposeHandle (since the handle is not a resource if the call fails -
  760. see below). 
  761.   In general there is no need to dispose of resource handles, because they
  762. are the responsibility of the Resource Manager. Resource handles must
  763. NEVER be disposed of via DisposeHandle, since that confuses the Resource
  764. Manager and you end up with heap corruption. (The Resource Manager does a
  765. DisposeHandle for all loaded resources in a resource file when the
  766. resource file is closed). 
  767.   If you feel the need to dispose of a resource handle when you're done
  768. with it (maybe because you'd like to free the memory that the resource is
  769. using) do it with the ReleaseResource call. It's generally better though
  770. to mark your resources as purgeable and leave it up to the Memory and
  771. Resource Managers to free the memory when needed. Be sure however, to use
  772. LoadResource in this case and mark the resource unpurgeable (or lock it)
  773. if you need to be sure that it doesn't "go away" while you're using it.
  774.  
  775. -- 
  776. Sigurdur Asgeirsson    | "Well you know, C isn't that hard, void (*(*f[])())()
  777. Kambasel 26            | for instance declares f as an array of unspecified
  778. 109 Reykjavik, Iceland | size, of pointers to functions that return pointers to
  779. sigurasg@rhi.hi.is     | functions that return void... I think"
  780.  
  781. +++++++++++++++++++++++++++
  782.  
  783. >From johns@efn.org (John Selhorst)
  784. Date: Tue, 8 Nov 1994 14:43:55 GMT
  785. Organization: hisself
  786.  
  787. In article <jones.794-071194191524@slip1-12.acs.ohio-state.edu>,
  788. jones.794@osu.edu (Matt Jones) wrote:
  789.  
  790. [ stuff from Roxanne deleted ]
  791.  
  792. > If your compiler is any good, it checks if any of the handles in local
  793. > storage are still attached. ( I think ) Otherwise, you would be unable to
  794. > find the handles to dispose of them later. However, this is tricky internal
  795. > compiler stuff, much like pre-initialized variables. I always explicitly
  796. > dispose of handles since the moment you assume your compiler does it for
  797. > you, it stops.
  798.  
  799. Wrong.  This is not fancy compiler stuff.  The handles Roxanne was
  800. referring to belong to the resource manager and the resource manager will
  801. dispose of them when it needs to.
  802.  
  803. Johnny
  804.  
  805. johns@efn.org
  806.  
  807. +++++++++++++++++++++++++++
  808.  
  809. >From Scott.Francis@SuperMac.com (eScott Francisternet alt.bbs.lists alt.bbs.lists.d alt.bbs.majorbbs alt.bbs.metal alt.bbs.pcboard alt.bbs.pcbuucp alt.bbs.renegade alt.bbs.searchlight alt.bbs.unixbbs alt.bbs.unixbbs.uniboard alt.bbs.uupcb alt.bbs.waffle alt.bbs.wildcat alt.beadworld alt.)
  810. Date: Tue, 08 Nov 1994 10:49:31 -0800
  811. Organization: Radius
  812.  
  813. In article <roxanne-0711941153320001@47.221.33.54>, roxanne@bnr.ca
  814. (Roxanne Friesen) wrote:
  815.  
  816. > I'm trying to get a better *handle* on when handles should be disposed of
  817. > and resources released.
  818.  
  819. In both cases the resource handle should be released with
  820. ReleaseResource().  Many programmers have not always done so, particularly
  821. when building apps since the res file will be closed (and all resources
  822. from that file released) when the app quits.  While calling
  823. ReleaseResource() is then not strictly necessary, it is good form, and can
  824. help some types of memory problems.
  825.  
  826. Another dimension to the problem:  If you will be refetching resources
  827. again and again, you might want to make the preloadable, and *not* release
  828. them.  This will keep them in memory and speed up the calls to
  829. GetResource().
  830.  
  831. --Scott
  832.  
  833. +++++++++++++++++++++++++++
  834.  
  835. >From mxmora@unix.sri.com (Matt Mora)
  836. Date: 8 Nov 1994 15:39:07 -0800
  837. Organization: SRI International, Menlo Park, CA
  838.  
  839. In article <roxanne-0711941153320001@47.221.33.54> roxanne@bnr.ca (Roxanne Friesen) writes:
  840. >I'm trying to get a better *handle* on when handles should be disposed of
  841. >and resources released.
  842.  
  843. Simple.  Handle are disposed and Resources are released.
  844.  
  845. >BEGIN
  846. >  result := NewAlias(NIL, fileSpec, alisHandle);
  847. >  IF (alisHandle <> NIL) THEN BEGIN
  848. >    AddResource(Handle(alisHandle), rAliasType, 128, 'File Alias');
  849.  
  850. At this point aliasHandle is no longer a plain ol handle. After you
  851. call Addresource the handle you supply becomes a ResourceHandle.
  852.  
  853. If its a resource handle what are you supposed to do with it? Yep
  854. ReleaseResource. 
  855.  
  856. DON'T CALL DISPOSEHANDLE AFTER YOU CALLED ADDRESOURCE ON THAT HANDLE.
  857.  
  858. >
  859. >In the second sample function below, again, I would have thought that the
  860. >resource should be released once I'm finished with it but, again, this
  861. >function doesn't do that.  Am I wrong, is this function wrong, or is it
  862. >simply not necessary, in this case, to release the resource?
  863.  
  864.  
  865. In the example that was shown, you don't have to call release resource
  866. if you might use that resource again. If you don't want it around
  867. go ahead and call release resource.
  868.  
  869. If the resource file is closed, the Resource handles will be released.
  870.  
  871. Xavier
  872.  
  873.  
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883. -- 
  884. ___________________________________________________________
  885. Matthew Xavier Mora                       Matt_Mora@sri.com
  886. SRI International                       mxmora@unix.sri.com
  887. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  888.  
  889. +++++++++++++++++++++++++++
  890.  
  891. >From mxmora@unix.sri.com (Matt Mora)
  892. Date: 8 Nov 1994 15:40:13 -0800
  893. Organization: SRI International, Menlo Park, CA
  894.  
  895. In article <jones.794-071194191524@slip1-12.acs.ohio-state.edu> jones.794@osu.edu (Matt Jones) writes:
  896.  
  897. >If your compiler is any good, it checks if any of the handles in local
  898. >storage are still attached. ( I think ) Otherwise, you would be unable to
  899. >find the handles to dispose of them later. However, this is tricky internal
  900. >compiler stuff, much like pre-initialized variables. I always explicitly
  901. >dispose of handles since the moment you assume your compiler does it for
  902. >you, it stops.
  903.  
  904.  
  905. Huh?
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913. Xavier
  914.  
  915. -- 
  916. ___________________________________________________________
  917. Matthew Xavier Mora                       Matt_Mora@sri.com
  918. SRI International                       mxmora@unix.sri.com
  919. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  920.  
  921. +++++++++++++++++++++++++++
  922.  
  923. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  924. Date: Wed, 09 Nov 1994 11:27:40 +0800
  925. Organization: NCRPDA, Curtin University
  926.  
  927. In article <roxanne-0711941153320001@47.221.33.54>, roxanne@bnr.ca
  928. (Roxanne Friesen) wrote:
  929.  
  930. >In the first sample function below, I would have thought that the alias
  931. >handle should be disposed of once the resource has been written to the
  932. >resource file but this function doesn't do that.  Am I wrong, is this
  933. >function wrong, or is it simply not necessary, in this case, to dispose of
  934. >the handle? (For the sake of simplifying the samples, assume I'm writing
  935. >to my apps own resource fork and not a prefs file of some kind ... or does
  936. >that make a difference?)
  937.  
  938. First off, you must never call DisposeHandle on a resource handle, nor
  939. ReleaseResource on a non-resource handle.  Bad THings(tm) will happen. 
  940. There are a pair fo inits (DoubleTrouble and DisposeResource or some such)
  941. that catch bugs like this, available from ftp.apple.com:/mac/dts/ I
  942. believe.
  943.  
  944. Second, when you write a resource to a file, it's not necessayr to release
  945. it afterwards, since it will be automatically released when the resource
  946. file is closed (which tends to be quite soon afterwards anyway).  Also,
  947. you can set the handle to be purged (HPurge) and then it'll be released
  948. when memory is needed, but not until.  Make sure to call GetResource again
  949. to reload the (possibly) purged handle before reusing it.
  950.  
  951. Enjoy,
  952.    Peter.
  953. -- 
  954. Peter N Lewis <peter.lewis@info.curtin.edu.au> - Macintosh TCP fingerpainter
  955.  
  956. ---------------------------
  957.  
  958. >From fallside@rahul.net (David C. Fallside)
  959. Subject: Prograph 2.5
  960. Date: 10 Nov 1994 06:39:19 GMT
  961. Organization: a2i network
  962.  
  963. I recently accepted a $59.95 offer for Prograph 2.5. The promo blurb "Very
  964. High Level Pictorial Object-Oriented Programming Environment" seems to be
  965. accurate, and having worked my way through half of the tutorials, it seems
  966. that it should be possible to develop complex applications. But I'm not a
  967. professional programmer, and haven't found anyone else who has ever heard
  968. of Prograph. Any comments from Netland? Thank you.
  969. David
  970.  
  971. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  972. I'd rather be on the river ....
  973. K1/4, SQRT/3
  974. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  975.  
  976. +++++++++++++++++++++++++++
  977.  
  978. >From nick+@pitt.edu ( nick.c )
  979. Date: Thu, 10 Nov 1994 11:42:38 -0500
  980. Organization: The Pitt, Chemistry
  981.  
  982. In article <fallside-0911942243270001@382.rahul.net>, fallside@rahul.net
  983. (David C. Fallside) wrote:
  984.  
  985. > I recently accepted a $59.95 offer for Prograph 2.5. The promo blurb "Very
  986. > High Level Pictorial Object-Oriented Programming Environment" seems to be
  987. > accurate, and having worked my way through half of the tutorials, it seems
  988. > that it should be possible to develop complex applications. But I'm not a
  989. > professional programmer, and haven't found anyone else who has ever heard
  990. > of Prograph. Any comments from Netland? Thank you.
  991.  
  992.  
  993.    Prograph was my first environment (not counting hypercard), and
  994.       I consider that a mistake.  Don't get me wrong - prograph is
  995.       both a great concept and a great engineering feet.  I still
  996.       argue that inconic input will be the way we'll all code 10 years
  997.       from now (or sooner).  However, prograph is a dual mode environment,
  998.       it allows you to program at a low level, but defaults to a high
  999.       level environment by use of it's integrated class library.
  1000.       As a result, and with the added factor there is very little
  1001.       sample code or literature, it's hard to tell where the library
  1002.       ends and the toolbox begins.  You can generate nice (albeit
  1003.       large and slow) apps with 2.5.2 - nicer ones with CPX - but
  1004.       you won't learn anything about Mac programming with it.
  1005.  
  1006.    To learn how to program the Mac you'll need to learn a classical
  1007.       low level language (Pascal or C would be best), and when you do
  1008.       you'll find you can generate much smaller, faster binaries and
  1009.       have access to a wealth of established library code and example
  1010.       code from all over the world.  My guess is most "professional"
  1011.       programmers, don't want to give up those advantages.
  1012.  
  1013.    Prograph was marketed as a non-programmers programming language, and
  1014.       I think that's still true.  However, as I said above, it does
  1015.       allow low level coding, is very powerfull, and has the best
  1016.       interface and debugger I've ever seen.  It's a glimpse of the
  1017.       future of programming, and worth knowing, just remeber you 
  1018.       get paid in the present.
  1019.  
  1020.  
  1021.  Internet: nick+@pitt.edu            _/   _/  _/  _/_/_/   _/   _/  
  1022.    eWorld: nick                     _/_/ _/  _/  _/   _/  _/_/_/ 
  1023.       CIS: 71232,766               _/ _/_/  _/  _/       _/ _/    
  1024.      http://www.pitt.edu/~nick/   _/   _/  _/   _/_/_/  _/   _/     
  1025.                     
  1026.  
  1027. +++++++++++++++++++++++++++
  1028.  
  1029. >From pjensen@netcom.com (Peter Jensen)
  1030. Date: Thu, 10 Nov 1994 16:53:40 GMT
  1031. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1032.  
  1033. fallside@rahul.net (David C. Fallside) writes:
  1034.  
  1035. >I recently accepted a $59.95 offer for Prograph 2.5. The promo blurb "Very
  1036. >High Level Pictorial Object-Oriented Programming Environment" seems to be
  1037. >accurate, and having worked my way through half of the tutorials, it seems
  1038. >that it should be possible to develop complex applications. But I'm not a
  1039. >professional programmer, and haven't found anyone else who has ever heard
  1040. >of Prograph. Any comments from Netland? Thank you.
  1041. >David
  1042.  
  1043. Prograph 2.5 is the predecessor of Prograph CPX 1.x, which is the 
  1044. Prograph development environment with all the bells and whistles.  $60 is 
  1045. a great price for 2.5 which has the full language implementation found in 
  1046. CPX.  CPX has a rich class library a'la TCL/MacApp and a user-modifiable 
  1047. GUI Builder.  
  1048.  
  1049. I use Prograph full-time to develop complex commercial applications.  
  1050. There are some very intriguing apps with high-volume potential being 
  1051. developed in Prograph right now.  Prograph has arguably one of the best 
  1052. debuggers ever implemented (in the interpretive mode).  There is an 
  1053. optimizing compiler that generates stand-alone apps.  The code isn't as 
  1054. fast or tight as C/C++ but you get RTTI, garbage collection, automatic 
  1055. deref of handles/pointers, cool list management stuff, and of course, a 
  1056. gorgreous visual syntax that prevents syntax errors via constrained input.
  1057.  
  1058. Visual Programming is for real; and Prograph is the most "real" of the new
  1059. generation.  It's one of the things that makes the Mac a special
  1060. development platform.  Sometime next year there will be a Windows Prograph
  1061. and the framework will become cross-platform.  Plus they're developing
  1062. DAL/SQL database tools that will allow you to do everything you can do in
  1063. Omnis/4D but drop into Prograph if you want real programming power.  For
  1064. compute-bound operations it's fairly straightforward to import external
  1065. primitives written in C if you feel the need for speed.  In normal usage,
  1066. you can't tell whether well-crafted apps were written in Prograph or C++ 
  1067. (well, maybe you can, since they're delivered earlier!). 
  1068.  
  1069. I'm very happy with Prograph.  net.persons interested in Prograph can join
  1070. the commotion over on comp.lang.prograph.  Also, Kurt Schmucker of Apple's
  1071. ATG has written an extensive review of CPX in November's MacTech.  Look
  1072. for more Prograph articles in coming issues. 
  1073.  
  1074. Peter Jensen                                  pjensen@netcom.com
  1075. Pepper Tree Design, Inc.                      Santa Clara, CA
  1076.    "Software crafted from the choicest of electrons" (tm)
  1077.  
  1078. +++++++++++++++++++++++++++
  1079.  
  1080. >From howardb@enlil.premenos.com (Howard Berkey)
  1081. Date: 10 Nov 1994 17:03:19 GMT
  1082. Organization: Premenos Corp
  1083.  
  1084. In article <fallside-0911942243270001@382.rahul.net>,
  1085. David C. Fallside <fallside@rahul.net> wrote:
  1086. >I recently accepted a $59.95 offer for Prograph 2.5. The promo blurb "Very
  1087. >High Level Pictorial Object-Oriented Programming Environment" seems to be
  1088. >accurate, and having worked my way through half of the tutorials, it seems
  1089. >that it should be possible to develop complex applications. But I'm not a
  1090. >professional programmer, and haven't found anyone else who has ever heard
  1091. >of Prograph. Any comments from Netland? Thank you.
  1092. >David
  1093. >
  1094.  
  1095.  
  1096.  
  1097.  
  1098. I've never used it myself but it gets a lot of praise from those who
  1099. have.  
  1100.  
  1101. You might want to check out comp.lang.prograph... I'm sure you'll get
  1102. a lot of info there.
  1103.  
  1104. -H-
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115. ---------------------------
  1116.  
  1117. >From ladan@cs.umd.edu (Ladan Gharai)
  1118. Subject: [Q] Programming with the QuickTime toolkit
  1119. Date: 2 Nov 1994 18:52:59 -0500
  1120. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  1121.  
  1122.  
  1123. Hi everyone
  1124.  
  1125. I am new to the QuickTime and am trying to understand how it works. I have
  1126. a bunch of questions and would appreciate any answers. I need to write a player
  1127. with very specific functionality. Going through the Inside the Mac: Quicktime
  1128. I have the following questions:
  1129.  
  1130. 1. A sample is defined as "A single element of a sequence of time-ordered
  1131.    data" does this mean that for a vedio a sample would be a frame?
  1132.  
  1133. 2. What function calls should I use to be able to access a single frame? In the
  1134.    Inside the Mac it says that a programmer can access every frame. How?
  1135.  
  1136. 3. Where does QuickTime store information about the frame rates (fps) of a movie? 
  1137.    For example the frame rate that a movie was created with? 
  1138.  
  1139. 4. Is there a realtionship between frame rate (fps) and playback rate?  
  1140.  
  1141. 5. When QuickTime does not have enough time to display all the frames of a
  1142.    movie, it starts dropping frames. Is there a pattern to this frame dropping?
  1143.    For example does it drop everyother frame, or the third in every 3 frames? 
  1144.    How does it decide which frames to drop?
  1145.  
  1146.  
  1147.  
  1148. thanx
  1149. Ladan
  1150.  
  1151. +++++++++++++++++++++++++++
  1152.  
  1153. >From rich@cs.umd.edu (Richard Gerber)
  1154. Date: 2 Nov 1994 19:44:03 -0500
  1155. Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
  1156.  
  1157. I am interested too.  But specifically: from within a quicktime player is there
  1158. any way to dynamically determine -- as the movie is playing -- which particular 
  1159. frames are being dropped.  
  1160.  
  1161. If not, what's the lowest level of granularity I can get to?
  1162.  
  1163. rich
  1164.  
  1165. - ----------
  1166.  
  1167. Richard Gerber
  1168. Assistant Professor
  1169.     
  1170. Department of Computer Science
  1171. University of Maryland
  1172. College Park, MD  20742 USA
  1173.  
  1174. Email:   rich@cs.umd.edu
  1175. Tel:     (301) 405-2710
  1176. FAX:     (301) 405-6707
  1177.  
  1178.  
  1179.  
  1180. +++++++++++++++++++++++++++
  1181.  
  1182. >From ivan_cavero_belaunde@avid.com (Ivan Cavero Belaunde)
  1183. Date: 8 Nov 1994 00:00:42 GMT
  1184. Organization: Avid Technology, Inc.
  1185.  
  1186. In article <3998qv$7id@mingus.cs.umd.edu>, ladan@cs.umd.edu (Ladan Gharai)
  1187. wrote:
  1188. > Hi everyone
  1189. > I am new to the QuickTime and am trying to understand how it works. I have
  1190. > a bunch of questions and would appreciate any answers. I need to write a
  1191. player
  1192. > with very specific functionality. Going through the Inside the Mac: Quicktime
  1193. > I have the following questions:
  1194. > 1. A sample is defined as "A single element of a sequence of time-ordered
  1195. >    data" does this mean that for a vedio a sample would be a frame?
  1196.  
  1197. Yup.
  1198.  
  1199. > 2. What function calls should I use to be able to access a single frame?
  1200. In the
  1201. >    Inside the Mac it says that a programmer can access every frame. How?
  1202.  
  1203. If I want the sample at time 10 on the first track:
  1204.    theTrack = GetMovieIndTrack(theMovie, 1);
  1205.    theMedia = GetTrackMedia(theTrack);
  1206.    mediaTime = TrackTimeToMediaTime(theTrack, 10);
  1207.    if (mediaTime != -1) {
  1208.       err = GetMediaSample(theMedia, sampleDataHandle, 0, &sampleDataSize,
  1209.             mediaTime, nil, nil, sampleDescriptionHandle, nil, 1, nil,
  1210.             &sampleFlags);
  1211.  
  1212. > 3. Where does QuickTime store information about the frame rates (fps) of
  1213. a movie? 
  1214. >    For example the frame rate that a movie was created with? 
  1215.  
  1216. It doesn't since the frame rate can vary over time throughout the movie.
  1217. You can estimate it by walking each track by track edits via
  1218. GetTrackNextInterestingTime and then figuring out the frame rate for each
  1219. edit by looking at the edit rate for each edit as well as the durations of
  1220. the samples spanned by the edit.
  1221.  
  1222. > 4. Is there a realtionship between frame rate (fps) and playback rate?  
  1223.  
  1224. I'm not sure what you mean here. The QuickTime movie will never play at a
  1225. better rate than its original stored rate - additionally, it is eminently
  1226. possible to create a movie with too high a stored frame rate that will not
  1227. play properly and will drop frames.
  1228.  
  1229. > 5. When QuickTime does not have enough time to display all the frames of a
  1230. >    movie, it starts dropping frames. Is there a pattern to this frame
  1231. dropping?
  1232. >    For example does it drop everyother frame, or the third in every 3 frames? 
  1233. >    How does it decide which frames to drop?
  1234.  
  1235. A movie has a "running clock" that tells it what "time" it is within the
  1236. movie. When falling behind, QT will drop as many frames as necessary to
  1237. catch up the frame being displayed with its running clock. The results are
  1238. dependent on boatloads of factors, such as the horsepower of your machine,
  1239. the bandwidth of your storage device, the seek speed of your storage
  1240. device, the compression scheme used, the frame-differencing
  1241. characteristics of the movie, and where within the movie the "playback
  1242. head" is. There's no simple answer, sorry.
  1243.  
  1244. Hope this helps. Followups redirected to comp.sys.mac.programmer.
  1245.  
  1246. -Ivan
  1247. - --
  1248. Ivan Cavero Belaunde (ivan_cavero_belaunde@avid.com)
  1249. Avid VideoShop Lead
  1250. Avid Technology, Inc.
  1251. Disclaimer:  All views expressed are entirely my own and do not
  1252. reflect  the opinions of Avid Technology, Inc.
  1253.  
  1254. ---------------------------
  1255.  
  1256. End of C.S.M.P. Digest
  1257. **********************
  1258.  
  1259.  
  1260.  
  1261.